<?php
namespace Cyfy\Modules\Book\Forms;

use \Cyfy\Modules\Forms;
use \Cyfy\Modules\User\Current;
use \Cyfy\Modules\Book\Module;

/**
 * Settings form.
 *
 * @author Dandelion <dandelion8888@gmail.com>
 * @version 0.1
 */
class Settings extends Forms\Form
{
    /** 
     * Form structure.
     */
    public function structure()
    {
        $this -> permission("Book", "administration");
        $this -> stay = true;
        
        $i = new Forms\TextBox("perPage", Module :: t(420));
        $i -> format = "number";
        $i -> minValue = 2;
        $i -> maxValue = 100;
        $i -> required = true;
        $this -> addItem($i);
        
        $i = new Forms\CheckBox("showTitle", Module :: t(450), "1");
        $this -> addItem($i);

        $b = new Forms\Button(Module :: t(430));
        $this -> addButton($b);
    }
    
    /**
     * Submitting.
     */
    public function submit()
    {
        \Cyfy\Modules\Book\Module :: define("perPage", $this->get("perPage"));
        \Cyfy\Modules\Book\Module :: define("showTitle", ($this->get("showTitle")) ? 1 : 0);
        \Cyfy\Message :: set(Module :: t(440));
        return true;
    }
}